package com.message.configuration;

import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.List;
import java.util.Properties;

@Data
@Component
@ConfigurationProperties(prefix = "spring.message")
public class MessageConfiguration {

    /**
     * 默认发送者
     */
    private String defaultClient="local";
    /**
     * 是否发送,默认不发送
     */
    private Boolean enable = false;
    /**
     * 本地消息
     */
    private List<LocalProperties> local=new ArrayList<>();
    /**
     * 邮件消息
     */
    private List<MailProperties> mail=new ArrayList<>();

    @Data
    public static class LocalProperties {
        /**
         * 是否发送
         */
        private Boolean enable = false;

        private String client;
    }


    /**
     * 发送方式
     */
    @Data
    public static class MailProperties {
        /**
         * 是否发送
         */
        private Boolean enable = false;

        private String client;

        private String host;

        private int port;

        private String password;

        private String protocol;

        private String userName;

        private String defaultEncoding;

        private String nick;

        private Boolean testConnection;

        private Properties properties;
    }


    /**
     * 发送方式
     */
    @Data
    public static class YunpianProperties {
        /**
         * 是否发送
         */
        private Boolean enable = false;

        private String client;

        private String apikey;

        private String version;
    }
    /**
     * 发送方式
     */
    @Data
    public static class DingTalkProperties {
        /**
         * 是否发送
         */
        private Boolean enable = false;

        private String client;

        private String appKey;

        private String appSecret;

        private Long agentId;

        private String msgType;
    }
}
